﻿using System.Data;
using System.Windows.Forms;
using SystemCustomers.DBUtils;

namespace SystemCustomers.ManageServices
{
    public class FormViewingServices
    {
        
        public static string Id { get; set; }

        public DataTable InitServicedatagrid()
        {
            return SingletonManagerDb.Instance.DbViewingServices();
        }

        public DialogResult EditService(DataGridViewRow dr)
        {
            using (var service = new ManageServiceType(dr.Cells["servicesName"].Value.ToString()))
            {
                Id = dr.Cells["idService_Services"].Value.ToString();
                service.btnAdd.Visible = false;
                MessageUtils.LogUtils.WriteToLog(string.Format(" Edit Row Viewing All Services: {0}", dr.Cells["servicesName"].Value));
                MessageUtils.LogUtils.SystemEventLogsInformation(string.Format(" Edit Row Viewing All Services: {0}", dr.Cells["servicesName"].Value));
                return service.ShowDialog();
            }
        }

        public void DeleteService(DataGridViewRow dr)
        {
            Id = dr.Cells["idService_Services"].Value.ToString();
            SingletonManagerDb.Instance.DeleteServiceRow(Id);
            MessageUtils.LogUtils.WriteToLog(" Delete Row Viewing All Services: " +
                                           dr.Cells["servicesName"].Value);
            MessageUtils.LogUtils.SystemEventLogsInformation(string.Format(" Delete Row Viewing All Services: {0}", dr.Cells["servicesName"].Value));
        }
    }
}
